# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Pete Alexandrou <pete@ozmartians.com>

pkgname=vidcutter
pkgver=6.0.5.1
pkgrel=7
pkgdesc='Modern, simple to use, constantly evolving and hella fast media cutter + joiner with frame-accurate SmartCut technology'
arch=('loong64' 'x86_64')
url='https://github.com/ozmartian/vidcutter'
license=('GPL3')
depends=('ffmpeg' 'mediainfo' 'mpv' 'python-opengl' 'python-pyqt5' 'python-simplejson')
makedepends=('python-setuptools' 'cython')
source=("https://github.com/ozmartian/$pkgname/archive/$pkgver/$pkgname-$pkgver.tar.gz"
        $pkgname-mpv-0-35-0-1.patch::https://github.com/ozmartian/vidcutter/commit/1d88825feb5a73a50d019914ba9d0008562a58ce.patch
        $pkgname-mpv-0-35-0-2.patch::https://github.com/ozmartian/vidcutter/commit/8010f5c64efe68d8130a036f976d2d2ff1c868ad.patch
        $pkgname-mpv-0-35-0-3.patch::https://github.com/ozmartian/vidcutter/commit/4cf1458d832e6ac7a824d7963c6dc3a0e5c17574.patch
        $pkgname-mpv-0-35-0-4.patch::https://github.com/ozmartian/vidcutter/commit/27c1ceb1764a86b284fb9115b9cf740891be1329.patch
        $pkgname-python310.patch::https://github.com/ozmartian/vidcutter/commit/85bf70698ed9.patch
        $pkgname-pyqt-crash.patch::https://github.com/ozmartian/vidcutter/commit/a9e929f4b7.patch)
sha256sums=('c6374eaedb845f9e580e555dd12c1db1cf2ffa28d3756b08e2ae28c1a4cd4a96'
            '5b79f29474e6868456151f2a7a481d47448099b36febf71cc08d64ffc3c80ddc'
            'f22ecf594bfaadd4fb262ab785e1be3dbfdcf023de29e8ffe81410cd1d3d3e96'
            'a93439542fe1a8b438965dcb7bf278cd3d1ec223d1ab03848fc8a774c2cbe57f'
            '493d025f449b8a7856b6fe75ecdb7c7c8631713ac9eba626b4ba07c83ec2fe9f'
            'e7f9ff874ff18c0be25ac3f48c164678684ad9e66de623733db8bc250f538a32'
            'dc7f9504dd373be35b049e69d701b79562773c502017b569143177a68bfea468')

prepare() {
  cd $pkgname-$pkgver
  # api changes for mpv 0.35.0
  patch -Np1 -i ../$pkgname-mpv-0-35-0-1.patch
  patch -Np1 -i ../$pkgname-mpv-0-35-0-2.patch
  patch -Np1 -i ../$pkgname-mpv-0-35-0-3.patch
  patch -Np1 -i ../$pkgname-mpv-0-35-0-4.patch
  # https://bugs.archlinux.org/task/73064
  patch -Np1 -i ../$pkgname-python310.patch
  # https://github.com/ozmartian/vidcutter/issues/369
  patch -Np1 -i ../$pkgname-pyqt-crash.patch
  # remove mpv.c so it gets regenerated by current cython
  rm vidcutter/libs/pympv/mpv.c
}

build() {
  cd $pkgname-$pkgver
  python setup.py build
}

package() {
  cd $pkgname-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
}
